package org.openurp.edu.student.info.web.action

import java.io.File
import org.beangle.webmvc.api.action.ActionSupport
import org.beangle.webmvc.api.annotation.param
import org.beangle.webmvc.api.view.Stream
import org.beangle.webmvc.api.view.View
import org.beangle.webmvc.entity.action.RestfulAction
import org.openurp.edu.student.info.model.Caze
import org.openurp.edu.student.info.model.Policy
import org.openurp.edu.student.info.model.Policyscope
import org.openurp.edu.student.info.model.Docfiled


/**
 * @author hjc
 */
class PolicyAction extends RestfulAction[Policy] {
  
  def file(@param("policyId") policyId:String):View={
    val policy = entityDao.get(classOf[Policy], java.lang.Long.valueOf(policyId))
    Stream(new File("D:\\tmp\\policy\\"+policy.code+".pdf"))
  }
  
   protected override def editSetting(entity: Policy): Unit = {
    put ("policyscopes", entityDao.getAll(classOf[Policyscope]))
    put ("docfileds", entityDao.getAll(classOf[Docfiled]))
   }
   
   def view(@param("policyId") policyId:String): String = {
    val policy = entityDao.get(classOf[Policy], java.lang.Long.valueOf(policyId))
    if (null != policy ) {
      val file = new File("D:\\tmp\\policy\\"+policy.code+".pdf")
      if (file.exists) put("policy", policy)
    }
    forward()
  }
   
   
   
   
  
}